home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 1.iso / toolbox / src / demos / OpenGL / ideas / draw_logo_line.c < prev    next >
C/C++ Source or Header  |  1996-11-11  |  10KB  |  381 lines

  1. /*
  2.  * (c) Copyright 1993, Silicon Graphics, Inc.
  3.  * ALL RIGHTS RESERVED 
  4.  * Permission to use, copy, modify, and distribute this software for 
  5.  * any purpose and without fee is hereby granted, provided that the above
  6.  * copyright notice appear in all copies and that both the copyright notice
  7.  * and this permission notice appear in supporting documentation, and that 
  8.  * the name of Silicon Graphics, Inc. not be used in advertising
  9.  * or publicity pertaining to distribution of the software without specific,
  10.  * written prior permission. 
  11.  *
  12.  * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
  13.  * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
  14.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
  15.  * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
  16.  * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
  17.  * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
  18.  * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
  19.  * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
  20.  * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
  21.  * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
  22.  * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
  23.  * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
  24.  * 
  25.  * US Government Users Restricted Rights 
  26.  * Use, duplication, or disclosure by the Government is subject to
  27.  * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
  28.  * (c)(1)(ii) of the Rights in Technical Data and Computer Software
  29.  * clause at DFARS 252.227-7013 and/or in similar or successor
  30.  * clauses in the FAR or the DOD or NASA FAR Supplement.
  31.  * Unpublished-- rights reserved under the copyright laws of the
  32.  * United States.  Contractor/manufacturer is Silicon Graphics,
  33.  * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
  34.  *
  35.  * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
  36.  */
  37. #include <GL/gl.h>
  38.  
  39. #include "objects.h"
  40.  
  41. float scp[14][3] = {
  42.     {1.000000, 0.000000, 0.000000},    {1.000000, 0.000000, 5.000000},
  43.     {0.500000, 0.866025, 0.000000},    {0.500000, 0.866025, 5.000000},
  44.     {-0.500000, 0.866025, 0.000000},    {-0.500000, 0.866025, 5.000000},
  45.     {-1.000000, 0.000000, 0.000000},    {-1.000000, 0.000000, 5.000000},
  46.     {-0.500000, -0.866025, 0.000000},    {-0.500000, -0.866025, 5.000000},
  47.     {0.500000, -0.866025, 0.000000},    {0.500000, -0.866025, 5.000000},
  48.     {1.000000, 0.000000, 0.000000},    {1.000000, 0.000000, 5.000000},
  49. };
  50.  
  51. float dcp[14][3] = {
  52.     {1.000000, 0.000000, 0.000000},    {1.000000, 0.000000, 7.000000},
  53.     {0.500000, 0.866025, 0.000000},    {0.500000, 0.866025, 7.000000},
  54.     {-0.500000, 0.866025, 0.000000},    {-0.500000, 0.866025, 7.000000},
  55.     {-1.000000, 0.000000, 0.000000},    {-1.000000, 0.000000, 7.000000},
  56.     {-0.500000, -0.866025, 0.000000},    {-0.500000, -0.866025, 7.000000},
  57.     {0.500000, -0.866025, 0.000000},    {0.500000, -0.866025, 7.000000},
  58.     {1.000000, 0.000000, 0.000000},    {1.000000, 0.000000, 7.000000},
  59. };
  60.  
  61. float ep[7][7][3] = {
  62.     {
  63.     {1.000000, 0.000000, 0.000000},
  64.     {0.500000, 0.866025, 0.000000},
  65.     {-0.500000, 0.866025, 0.000000},
  66.     {-1.000000, 0.000000, 0.000000},
  67.     {-0.500000, -0.866025, 0.000000},
  68.     {0.500000, -0.866025, 0.000000},
  69.     {1.000000, 0.000000, 0.000000},
  70.     },
  71.  
  72.     {
  73.     {1.000000, 0.034074, 0.258819},
  74.     {0.500000, 0.870590, 0.034675},
  75.     {-0.500000, 0.870590, 0.034675},
  76.     {-1.000000, 0.034074, 0.258819},
  77.     {-0.500000, -0.802442, 0.482963},
  78.     {0.500000, -0.802442, 0.482963},
  79.     {1.000000, 0.034074, 0.258819},
  80.     },
  81.  
  82.     {
  83.     {1.000000, 0.133975, 0.500000},
  84.     {0.500000, 0.883975, 0.066987},
  85.     {-0.500000, 0.883975, 0.066987},
  86.     {-1.000000, 0.133975, 0.500000},
  87.     {-0.500000, -0.616025, 0.933013},
  88.     {0.500000, -0.616025, 0.933013},
  89.     {1.000000, 0.133975, 0.500000},
  90.     },
  91.  
  92.     {
  93.     {1.000000, 0.292893, 0.707107},
  94.     {0.500000, 0.905266, 0.094734},
  95.     {-0.500000, 0.905266, 0.094734},
  96.     {-1.000000, 0.292893, 0.707107},
  97.     {-0.500000, -0.319479, 1.319479},
  98.     {0.500000, -0.319479, 1.319479},
  99.     {1.000000, 0.292893, 0.707107},
  100.     },
  101.  
  102.     {
  103.     {1.000000, 0.500000, 0.866025},
  104.     {0.500000, 0.933013, 0.116025},
  105.     {-0.500000, 0.933013, 0.116025},
  106.     {-1.000000, 0.500000, 0.866025},
  107.     {-0.500000, 0.066987, 1.616025},
  108.     {0.500000, 0.066987, 1.616025},
  109.     {1.000000, 0.500000, 0.866025},
  110.     },
  111.  
  112.     {
  113.     {1.000000, 0.741181, 0.965926},
  114.     {0.500000, 0.965325, 0.129410},
  115.     {-0.500000, 0.965325, 0.129410},
  116.     {-1.000000, 0.741181, 0.965926},
  117.     {-0.500000, 0.517037, 1.802442},
  118.     {0.500000, 0.517037, 1.802442},
  119.     {1.000000, 0.741181, 0.965926},
  120.     },
  121.  
  122.     {
  123.     {1.000000, 1.000000, 1.000000},
  124.     {0.500000, 1.000000, 0.133975},
  125.     {-0.500000, 1.000000, 0.133975},
  126.     {-1.000000, 1.000000, 1.000000},
  127.     {-0.500000, 1.000000, 1.866025},
  128.     {0.500000, 1.000000, 1.866025},
  129.     {1.000000, 1.000000, 1.000000},
  130.     },
  131.  
  132. };
  133.  
  134. void draw_single_cylinder(void) {
  135.  
  136.     glBegin(GL_LINE_STRIP);
  137. glVertex3fv(scp[0]);
  138. glVertex3fv(scp[1]);
  139. glVertex3fv(scp[2]);
  140. glVertex3fv(scp[3]);
  141. glVertex3fv(scp[4]);
  142. glVertex3fv(scp[5]);
  143. glVertex3fv(scp[6]);
  144. glVertex3fv(scp[7]);
  145. glVertex3fv(scp[8]);
  146. glVertex3fv(scp[9]);
  147. glVertex3fv(scp[10]);
  148. glVertex3fv(scp[11]);
  149. glVertex3fv(scp[12]);
  150. glVertex3fv(scp[13]);
  151.     glEnd();
  152. }
  153.  
  154. void draw_double_cylinder(void) {
  155.  
  156.     glBegin(GL_LINE_STRIP);
  157. glVertex3fv(dcp[0]);
  158. glVertex3fv(dcp[1]);
  159. glVertex3fv(dcp[2]);
  160. glVertex3fv(dcp[3]);
  161. glVertex3fv(dcp[4]);
  162. glVertex3fv(dcp[5]);
  163. glVertex3fv(dcp[6]);
  164. glVertex3fv(dcp[7]);
  165. glVertex3fv(dcp[8]);
  166. glVertex3fv(dcp[9]);
  167. glVertex3fv(dcp[10]);
  168. glVertex3fv(dcp[11]);
  169. glVertex3fv(dcp[12]);
  170. glVertex3fv(dcp[13]);
  171.     glEnd();
  172. }
  173.  
  174. void draw_elbow(void) {
  175.  
  176.     glBegin(GL_LINE_STRIP);
  177.         glVertex3fv(ep[0][0]);
  178.         glVertex3fv(ep[1][0]);
  179.         glVertex3fv(ep[0][1]);
  180.         glVertex3fv(ep[1][1]);
  181.         glVertex3fv(ep[0][2]);
  182.         glVertex3fv(ep[1][2]);
  183.         glVertex3fv(ep[0][3]);
  184.         glVertex3fv(ep[1][3]);
  185.         glVertex3fv(ep[0][4]);
  186.         glVertex3fv(ep[1][4]);
  187.         glVertex3fv(ep[0][5]);
  188.         glVertex3fv(ep[1][5]);
  189.         glVertex3fv(ep[0][6]);
  190.         glVertex3fv(ep[1][6]);
  191.     glEnd();
  192.  
  193.     glBegin(GL_LINE_STRIP);
  194.         glVertex3fv(ep[1][0]);
  195.         glVertex3fv(ep[2][0]);
  196.         glVertex3fv(ep[1][1]);
  197.         glVertex3fv(ep[2][1]);
  198.         glVertex3fv(ep[1][2]);
  199.         glVertex3fv(ep[2][2]);
  200.         glVertex3fv(ep[1][3]);
  201.         glVertex3fv(ep[2][3]);
  202.         glVertex3fv(ep[1][4]);
  203.         glVertex3fv(ep[2][4]);
  204.         glVertex3fv(ep[1][5]);
  205.         glVertex3fv(ep[2][5]);
  206.         glVertex3fv(ep[1][6]);
  207.         glVertex3fv(ep[2][6]);
  208.     glEnd();
  209.  
  210.     glBegin(GL_LINE_STRIP);
  211.         glVertex3fv(ep[2][0]);
  212.         glVertex3fv(ep[3][0]);
  213.         glVertex3fv(ep[2][1]);
  214.         glVertex3fv(ep[3][1]);
  215.         glVertex3fv(ep[2][2]);
  216.         glVertex3fv(ep[3][2]);
  217.         glVertex3fv(ep[2][3]);
  218.         glVertex3fv(ep[3][3]);
  219.         glVertex3fv(ep[2][4]);
  220.         glVertex3fv(ep[3][4]);
  221.         glVertex3fv(ep[2][5]);
  222.         glVertex3fv(ep[3][5]);
  223.         glVertex3fv(ep[2][6]);
  224.         glVertex3fv(ep[3][6]);
  225.     glEnd();
  226.  
  227.     glBegin(GL_LINE_STRIP);
  228.         glVertex3fv(ep[3][0]);
  229.         glVertex3fv(ep[4][0]);
  230.         glVertex3fv(ep[3][1]);
  231.         glVertex3fv(ep[4][1]);
  232.         glVertex3fv(ep[3][2]);
  233.         glVertex3fv(ep[4][2]);
  234.         glVertex3fv(ep[3][3]);
  235.         glVertex3fv(ep[4][3]);
  236.         glVertex3fv(ep[3][4]);
  237.         glVertex3fv(ep[4][4]);
  238.         glVertex3fv(ep[3][5]);
  239.         glVertex3fv(ep[4][5]);
  240.         glVertex3fv(ep[3][6]);
  241.         glVertex3fv(ep[4][6]);
  242.     glEnd();
  243.  
  244.     glBegin(GL_LINE_STRIP);
  245.         glVertex3fv(ep[4][0]);
  246.         glVertex3fv(ep[5][0]);
  247.         glVertex3fv(ep[4][1]);
  248.         glVertex3fv(ep[5][1]);
  249.         glVertex3fv(ep[4][2]);
  250.         glVertex3fv(ep[5][2]);
  251.         glVertex3fv(ep[4][3]);
  252.         glVertex3fv(ep[5][3]);
  253.         glVertex3fv(ep[4][4]);
  254.         glVertex3fv(ep[5][4]);
  255.         glVertex3fv(ep[4][5]);
  256.         glVertex3fv(ep[5][5]);
  257.         glVertex3fv(ep[4][6]);
  258.         glVertex3fv(ep[5][6]);
  259.     glEnd();
  260.  
  261.     glBegin(GL_LINE_STRIP);
  262.         glVertex3fv(ep[5][0]);
  263.         glVertex3fv(ep[6][0]);
  264.         glVertex3fv(ep[5][1]);
  265.         glVertex3fv(ep[6][1]);
  266.         glVertex3fv(ep[5][2]);
  267.         glVertex3fv(ep[6][2]);
  268.         glVertex3fv(ep[5][3]);
  269.         glVertex3fv(ep[6][3]);
  270.         glVertex3fv(ep[5][4]);
  271.         glVertex3fv(ep[6][4]);
  272.         glVertex3fv(ep[5][5]);
  273.         glVertex3fv(ep[6][5]);
  274.         glVertex3fv(ep[5][6]);
  275.         glVertex3fv(ep[6][6]);
  276.     glEnd();
  277. }
  278.  
  279. void bend_forward(void) {
  280.   glTranslatef(0.0, 1.000000, 0.0);
  281.   glRotatef (0.1 * (900), 1.0, 0.0, 0.0);
  282.   glTranslatef(0.0, -1.000000, 0.0);
  283. }
  284.  
  285. void bend_left(void) {
  286.   glRotatef (0.1 * (-900), 0.0, 0.0, 1.0);
  287.   glTranslatef(0.0, 1.000000, 0.0);
  288.   glRotatef (0.1 * (900), 1.0, 0.0, 0.0);
  289.   glTranslatef(0.0, -1.000000, 0.0);
  290. }
  291.  
  292. void bend_right(void) {
  293.   glRotatef (0.1 * (900), 0.0, 0.0, 1.0);
  294.   glTranslatef(0.0, 1.000000, 0.0);
  295.   glRotatef (0.1 * (900), 1.0, 0.0, 0.0);
  296.   glTranslatef(0.0, -1.000000, 0.0);
  297. }
  298.  
  299. void draw_logo_line(void) {
  300.  
  301.     if( MAT_LOGO) {
  302.       glCallList( MAT_LOGO); 
  303.     }
  304.  
  305.     glTranslatef(5.500000,  -3.500000,  4.500000);
  306.  
  307.     glTranslatef(0.0,  0.0,  -7.000000);
  308.     draw_double_cylinder();
  309.     bend_forward();
  310.     draw_elbow();
  311.     glTranslatef(0.0,  0.0,  -7.000000);
  312.     draw_double_cylinder();
  313.     bend_forward();
  314.     draw_elbow();
  315.     glTranslatef(0.0,  0.0,  -5.000000);
  316.     draw_single_cylinder();
  317.     bend_right();
  318.     draw_elbow();
  319.     glTranslatef(0.0,  0.0,  -7.000000);
  320.     draw_double_cylinder();
  321.     bend_forward();
  322.     draw_elbow();
  323.     glTranslatef(0.0,  0.0,  -7.000000);
  324.     draw_double_cylinder();
  325.     bend_forward();
  326.     draw_elbow();
  327.     glTranslatef(0.0,  0.0,  -5.000000);
  328.     draw_single_cylinder();
  329.     bend_left();
  330.     draw_elbow();
  331.     glTranslatef(0.0,  0.0,  -7.000000);
  332.     draw_double_cylinder();
  333.     bend_forward();
  334.     draw_elbow();
  335.     glTranslatef(0.0,  0.0,  -7.000000);
  336.     draw_double_cylinder();
  337.     bend_forward();
  338.     draw_elbow();
  339.     glTranslatef(0.0,  0.0,  -5.000000);
  340.     draw_single_cylinder();
  341.     bend_right();
  342.     draw_elbow();
  343.     glTranslatef(0.0,  0.0,  -7.000000);
  344.     draw_double_cylinder();
  345.     bend_forward();
  346.     draw_elbow();
  347.     glTranslatef(0.0,  0.0,  -7.000000);
  348.     draw_double_cylinder();
  349.     bend_forward();
  350.     draw_elbow();
  351.     glTranslatef(0.0,  0.0,  -5.000000);
  352.     draw_single_cylinder();
  353.     bend_left();
  354.     draw_elbow();
  355.     glTranslatef(0.0,  0.0,  -7.000000);
  356.     draw_double_cylinder();
  357.     bend_forward();
  358.     draw_elbow();
  359.     glTranslatef(0.0,  0.0,  -7.000000);
  360.     draw_double_cylinder();
  361.     bend_forward();
  362.     draw_elbow();
  363.     glTranslatef(0.0,  0.0,  -5.000000);
  364.     draw_single_cylinder();
  365.     bend_right();
  366.     draw_elbow();
  367.     glTranslatef(0.0,  0.0,  -7.000000);
  368.     draw_double_cylinder();
  369.     bend_forward();
  370.     draw_elbow();
  371.     glTranslatef(0.0,  0.0,  -7.000000);
  372.     draw_double_cylinder();
  373.     bend_forward();
  374.     draw_elbow();
  375.     glTranslatef(0.0,  0.0,  -5.000000);
  376.     draw_single_cylinder();
  377.     bend_left();
  378.     draw_elbow();
  379. }
  380.  
  381.